import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;


public class JDBCDemo {

	public static void main(String[] args) throws ReflectiveOperationException, SQLException{
	  Class.forName("com.mysql.jdbc.Driver");
	  String url = "jdbc:mysql://localhost:3306/jdbc";
	  String user = "root";
	  String password = "root";
	  Connection conn = (Connection) DriverManager.getConnection(url, user, password);
	  Statement stmt = (Statement) conn.createStatement();
	  String sql = "SELECT * FROM Userdetail WHERE sex='1'";
	  ResultSet rs = stmt.executeQuery(sql);
	  rs.next();
	  String name = rs.getString(2);
	  System.out.println(name);
	  rs.close();
	  stmt.close();
	  conn.close();
	}
}
